﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ServerLibrary.Infrastructure;

namespace ServerLibrary.Abstract
{
     /// <summary>
    /// TaskHandler which organizes task processing.
    /// </summary>
  
    
    public interface ITaskHandler
    {
        /// <summary>
        /// Raises when task finished
        /// </summary>
        event TaskFinishedHandler TaskFinished;

        /// <summary>
        /// Return active Tasks count in queue
        /// </summary>
        int ActiveTaskCount { get; }

        /// <summary>
        /// Adds taks to ThreadPool queue
        /// </summary>
        /// <param name="task">Task to be added</param>
        void AddTask(ITask task);

        /// <summary>
        /// Get number of available threads
        /// </summary>
        /// <returns>number of available threads</returns>
        int GetAvailableThreads();

        /// <summary>
        /// Set max number of threads in ThreadPool
        /// </summary>
        /// <param name="workerThreads">Number of work threads</param>
        /// <param name="completionPortThreads">Number of completion threads</param>
        /// <returns></returns>
        bool SetMaxThreads(int workerThreads, int completionPortThreads);

        /// <summary>
        /// Set min number of threads in ThreadPool
        /// </summary>
        /// <param name="workerThreads">Number of work threads</param>
        /// <param name="completionPortThreads">Number of completion threads</param>
        /// <returns></returns>
        bool SetMinThreads(int workerThreads, int completionPortThreads);
                
    }
}
